package com.lingyue.entity.module.es.doc;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.annotations.DateFormat;
import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldType;

import java.util.Date;

/**
 * Created by IntelliJ IDEA.
 *
 * @Description: TODO
 * @Author: BaiJinhua
 * @Date: 2019/12/10 14:53
 * @See: com.lingyue.entity.module.es.doc
 * @Version: 1.0
 * Copyright: Copyright (c) 2019
 */
@Getter
@Setter
@ToString
@Document(indexName = "dump_logs", shards = 3, type = "_doc")
public class EsDumpLogsDocument {

    @Field(value = "createDate", type = FieldType.Date, format = DateFormat.custom, pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date createDate;

    @Field(value = "createUser", type = FieldType.Keyword)
    private String createUser;

    @ApiModelProperty(value = "批次码")
    @Field(value = "batchId", type = FieldType.Keyword)
    private String batchId;

    @ApiModelProperty(value = "数据总量")
    @Field(value = "total", type = FieldType.Long)
    private Long total;

    @ApiModelProperty(value = "子批次码")
    @Field(value = "batchSpanId", type = FieldType.Keyword)
    private String batchSpanId;

    @ApiModelProperty(value = "子批次数据量")
    @Field(value = "spanCount", type = FieldType.Integer)
    private Integer spanCount;

    @ApiModelProperty(value = "导入有效数，es中不存在的数量")
    @Field(value = "validNum", type = FieldType.Integer)
    private Integer validNum;

    @ApiModelProperty(value = "标签：opt/cus")
    @Field(value = "tag", type = FieldType.Keyword)
    private String tag;

    @Field(value = "startDate", type = FieldType.Date, format = DateFormat.custom, pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date startDate;

    @ApiModelProperty(value = "任务消耗时间，毫秒")
    @Field(value = "spendTimeMillis", type = FieldType.Long)
    private Long spendTimeMillis;

    @Id
    @Field(value = "id", type = FieldType.Long)
    @JsonSerialize(using = ToStringSerializer.class)
    private Long id;
}
